# Contributor: kpcyrd <git@rxv.cc>
# Maintainer: kpcyrd <git@rxv.cc>
pkgname=cargo-watch
pkgver=8.1.2
pkgrel=1
pkgdesc="Utility for Cargo to compile projects when sources change"
url="https://github.com/watchexec/cargo-watch"
# s390x and riscv64 blocked by cargo
arch="all !s390x !riscv64"
license="CC0-1.0"
makedepends="cargo"
subpackages="$pkgname-doc
	$pkgname-zsh-completion
	"
options="net"
source="$pkgname-$pkgver.tar.gz::https://github.com/watchexec/cargo-watch/archive/v$pkgver.tar.gz"

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo build --release --frozen
}

check() {
	PATH="$PWD/target/release:$PATH" cargo test --release --frozen
}

package() {
	cargo install --locked --root "$pkgdir/usr" --path .

	install -Dm 644 -t "$pkgdir/usr/share/doc/cargo-watch" README.md
	install -Dm 644 cargo-watch.1 -t "$pkgdir/usr/share/man/man1"
	install -Dm 644 completions/zsh "$pkgdir/usr/share/zsh/site-functions/_cargo-watch"

	rm "$pkgdir"/usr/.crates.toml
	rm "$pkgdir"/usr/.crates2.json
}

sha512sums="
3a62091eb382ce4c90426bef3b7aa7a6b9e68c876531d98f5222da29b409705b9ed92c60aa79f73eed3ee406e92e3233bd009ab5944665b9b27cee76de7206e4  cargo-watch-8.1.2.tar.gz
"
